package cn.kgc.jdktest.demo10;

import java.util.function.Consumer;
import java.util.stream.Stream;

/**
 * @Author:yaozhaobao
 * @Description:TODO
 * @version:1.0
 */
public class Test2 {

    public static void main(String[] args) {
        Stream<String> country = Stream.of("美国", "德国", "英国", "俄罗斯", "澳大利亚");
        //匿名内部类的写法
//        country.forEach(new Consumer<String>() {
//            @Override
//            public void accept(String s) {
//                System.out.println(s);
//            }
//        });


        //lamda写法
//        country.forEach(t -> System.out.println(t));

        //还可以在简化
//        country.forEach(System.out::println);

        Test2 test2 = new Test2();
        country.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                test2.print(s);
            }
        });

//        country.forEach(Test2::print);

//
//        country.forEach(test2::print);
    }


    public void print(String s){
        System.out.println(s);
    }
}
